<?php $baseUrl=Zend_Controller_Front::getInstance()->getBaseUrl(); ?>

<table width="100%">
<tr>
    <td>
        <a onclick="setCurrentPageRecommendBook(-1);"><img src="<?php echo $baseUrl. '/images/arrow1.png'; ?>" alt="" id="backrecommendbook" /></a>
    </td>
    <?php
    for($i=($this->currentPage - 1)*$this->pagesize;$i< $this->currentPage*$this->pagesize;$i++)
    {
        if($i>=count($this->recommendbook))
                break;
    ?>
        <td class="book">
            <a href="<?php echo $baseUrl . '/default/book/detail/id/'.$this->recommendbook[$i]["_id"]; ?>">
                <img src="<?php echo $this->recommendbook[$i]["image"];  ?>" alt="" class="abook"/>
            </a>
            <br/>
            <a href="<?php echo $baseUrl . '/default/book/detail/id/'.$this->recommendbook[$i]["_id"]; ?>">
            <?php
                if(strlen($this->recommendbook[$i]["name"])>20)
                {
                    $pos=strpos($this->recommendbook[$i]["name"], " ", 20);
                    if($pos!=False)
                    {
                        echo substr($this->recommendbook[$i]["name"], 0,$pos+1).'...';
                    }
                    else
                        echo $this->recommendbook[$i]["name"];
                }
                else
                    echo $this->recommendbook[$i]["name"];
            ?>
            </a><br/>
            Tác giả:
            <a>
            <?php
                if(strlen($this->recommendbook[$i]["author"])>15)
                {
                    $pos=strpos($this->recommendbook[$i]["author"], " ", 15);
                    if($pos!=False)
                    {
                        echo substr($this->recommendbook[$i]["author"], 0,$pos+1).'...';
                    }
                    else
                        echo $this->recommendbook[$i]["author"];
                }
                else
                    echo $this->recommendbook[$i]["author"];
            ?>
            </a><br/>
             <span class="rating">
                <?php
                    if($this->recommendbook[$i]["sumrating"]==2)
                            echo '<img alt="" src="'. $baseUrl .'/images/stars-2-0.gif"/><br/>' ;
                    if($this->recommendbook[$i]["sumrating"]==3)
                            echo '<img alt="" src="'. $baseUrl .'/images/stars-3-0.gif"/><br/>' ;
                    if($this->recommendbook[$i]["sumrating"]==4)
                            echo '<img alt="" src="'. $baseUrl .'/images/stars-4-0.gif"/><br/>' ;
                    if($this->recommendbook[$i]["sumrating"]==5)
                            echo '<img alt="" src="'. $baseUrl .'/images/stars-5-0.gif"/><br/>' ;
                ?>
            </span>
            <?php
                if((int)$this->recommendbook[$i]["view"] >0)
                {
                    echo '<span class="view">'.$this->recommendbook[$i]["view"].'  </span>người đã xem<br/>';
                }
            ?>
            <?php
                if(((int)$this->recommendbook[$i]["saleoff"])>0)
                {
                    echo "<span class='oldprice'>Giá gốc:".$this->recommendbook[$i]["cost"]." đ</span><br/>";
                    echo "<span class='price'>Giá bán:".($this->recommendbook[$i]["cost"]*(100-$this->recommendbook[$i]["saleoff"])/100)." đ</span>";
                }
                else
                    echo "<span class='price'>Giá bán:".$this->recommendbook[$i]["cost"]." đ</span>";
            ?>
        </td>
    <?php }?>
    <td>
        <a onclick="setCurrentPageRecommendBook(1);"><img src="<?php echo $baseUrl. '/images/arrow2.png'; ?>" alt="" id="nexrecommendbook" /></a>
    </td>
</tr>
</table>